package com.moli.iov.open.web.controller;

import com.moli.iov.base.model.dto.req.VehicleBaseAuthDto;
import com.moli.iov.open.model.vo.req.VehicleAuthVo;
import com.moli.iov.open.service.VehicleService;
import com.moli.iov.rest.RestResponse;
import com.moli.iov.util.CommonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * The type Vehicle controller.
 *
 * @author wanghualin
 * @date 2020 -06-15 11:46:38
 */
@Slf4j
@RestController
@RequestMapping("/api/vehicle")
public class VehicleController extends BaseController{


    @Autowired
    private VehicleService vehicleService;
    /**
     * 车辆授权
     */
    @PostMapping("/isAuth")
    public RestResponse vehicleAuth(@Validated  @RequestBody VehicleAuthVo  vo){
        log.info("OP 添加围栏绑定车辆入参：{}", vo);
        assembleUserInfo(vo);
        VehicleBaseAuthDto dto = new VehicleBaseAuthDto();
        CommonUtils.copyProperties(vo, dto);
       return vehicleService.updateAuthVehicle(dto);
    }
}
